knitr::opts_chunk$set(echo = TRUE)

library(tidyverse)
## Warning: package 'tidyverse' was built under R version 3.6.1
## -- Attaching packages ------------------------------------------------------------------------------------------- tidyverse 1.2.1 --
## v ggplot2 3.2.1     v purrr   0.3.2
## v tibble  2.1.3     v dplyr   0.8.3
## v tidyr   1.0.0     v stringr 1.4.0
## v readr   1.3.1     v forcats 0.4.0
## Warning: package 'ggplot2' was built under R version 3.6.1
## Warning: package 'tidyr' was built under R version 3.6.1
## Warning: package 'dplyr' was built under R version 3.6.1
## Warning: package 'stringr' was built under R version 3.6.3
## -- Conflicts ---------------------------------------------------------------------------------------------- tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag()    masks stats::lag()
library(here)
## Warning: package 'here' was built under R version 3.6.3
## here() starts at C:/Users/atredennick/repos/COVID-stochastic-fitting
allfiles <- list.files("../output/2020-06-21/")

for(f in allfiles) {
  fname <- paste0("../output/2020-06-21/",f)
dat <- read.csv(fname) %>%
  filter(variable %in% c("actual_daily_cases")) %>%
  mutate(date = as.Date(date))

read.csv(fname) %>%
  filter(variable %in% c("daily_cases")) %>%
  filter(sim_type == "status_quo") %>%
  mutate(date = as.Date(date)) %>%
  filter(date <= (Sys.Date() + 7*4)) %>%
  ggplot(aes(x = date, y = median_value)) +
  geom_ribbon(aes(ymin = lower_80, ymax = upper_80), alpha = 0.2) +
  geom_line() +
  geom_line(data = dat, aes(x = date, y = mean_value), color = "blue") +
  ggtitle(f) -> out
print(out)

read.csv(fname) %>%
  filter(variable %in% c("combined_trend", "latent_trend", "mobility_trend")) %>%
  filter(sim_type == "linear_increase_sd") %>%
  mutate(date = as.Date(date)) %>%
  ggplot(aes(x = date, y = mean_value)) +
  geom_point(aes(color = variable)) +
  ggtitle(f) -> out2
print(out2)
}